#!/usr/bin/env python

import random, io, datetime

from flask import Flask
app = Flask(__name__)


def suiji():
	jieguo1 = []
	jieguo2 = []
	while 1:
		shuzhi = random.randint(1,11)
		if shuzhi not in jieguo1:
			jieguo1.append(shuzhi)
		if len(jieguo1) == 5:
			break
	for shizhi1 in reversed(range(len(jieguo1))):
    		shuzhi2 = jieguo1.pop(shizhi1)
    		if shuzhi2 < 10:
      			jieguo2.append("0" + str(shuzhi2))
    		if shuzhi2 >= 10:
      			jieguo2.append(str(shuzhi2))

	return str(jieguo2)

def duquhangshu():

	fp = io.open("/home/b-liujw/jieguo.txt",'rb')
	hangshu = len(fp.readlines())
	fp.close()
	return str(hangshu)


def xieru(jieguo, shijian, hangshu):
	fp = io.open("/home/b-liujw/jieguo.txt", "a+b")
	fp.write(shijian + "/" + jieguo + "/" + hangshu + "\n")
	fp.close()


if __name__ == "__main__":
	shijian = datetime.datetime.now().strftime("%Y-%m_%d %H:%M:%S")
	xieru(suiji(), shijian, duquhangshu())
		
